package com.example.javamaday.leetcode;

public class LeetCodeTest0026 {

    public static void main(String[] args) {

    }

    public int removeDuplicates(int[] nums) {
        if (nums.length <= 1) {
            return nums.length;
        }
        int index = 0;
        int currentNum = nums[0];
        for (int i = 1; i < nums.length; i++) {
            if (currentNum != nums[i]) {
                currentNum = nums[i];
                index++;
                int temp = nums[index];
                nums[index] = nums[i];
                nums[i] = temp;
            }
        }
        return index + 1;
    }


}
